package it.eng.area118.mdocommon.ebus;

import java.io.Serializable;


/**
 * 
 * @author Luigi Bifulco
 * 
 */
public interface EventBusService {

	/**
	 * init the service using the broker identified by host:port Stabilisce una
	 * connessione verso il server
	 * 
	 * @param host
	 * @param port
	 */
	public void init(String host, int port, EBusServiceStateListener listener)
			throws Exception;

	/**
	 * destroy the service releasing all connections
	 */
	public void destroy();



	/**
	 * 
	 * @param topicID
	 * @param msg
	 * @return
	 */
	public boolean publish(String topicID,
			EBusMessage<? extends Serializable> msg);

	/**
	 * 
	 * @throws Exception
	 *             Chiama stop e poi start
	 */
	public void reset() throws Exception;

	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public boolean start() throws Exception;

	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public boolean stop() throws Exception;

	/**
	 * 
	 * @param login
	 */
	public void login(String login);

	public boolean subscribe(String topicID, EBusMessageHandler handler,
			Class messageType);

	// TODO: send?

}
